package language.monkey.cli

import language.monkey.laxer.Lexer
import language.monkey.token.TokenType

/**
 * 词法分析器
 */
class TokenRepl {

    companion object {
        @JvmStatic
        fun main(args: Array<String>) {
            println("Welcome to Monkey programming language!")
            println("Please input your code:")

            while (true) {
                print(">> ")
                val line = readlnOrNull() ?: break
                val lexer = Lexer(line)
                while (true) {
                    val token = lexer.nextToken()
                    if (token.type == TokenType.EOF) {
                        break
                    }
                    println(token)
                }
            }
        }
    }
}